package org.niu.str;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

public class Trans {
    public String trans(String s, int n) {
        // write code here
        String[] strs = s.split(" ");
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = strs.length-1; i >=0; i--) {
            char[] chs = strs[i].toCharArray();
            for (int j = 0; j < chs.length; j++) {
                if(chs[j] >= 'a' && chs[j]<='z'){
                    chs[j] = Character.toUpperCase(chs[j]);
                }
                else if(chs[j] <= 'Z' && chs[j] >='A'){
                    chs[j] = Character.toLowerCase(chs[j]);
                }
            }
            stringBuilder.append(chs);
            if(i!=0){
                stringBuilder.append(" ");
            }
        }
        if(s.charAt(n-1) == ' '){
            stringBuilder.insert(0," ");
        }
        return stringBuilder.toString();
    }
}
